# This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform".
#
# (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved.
#
# Please visit http://javatelnet.org/ for updates and contact.
#
# --LICENSE NOTICE--
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# --LICENSE NOTICE--
#

JAVA	=	java
JAR	=	jar
JAVAC	=	javac
JAVADOC =	javadoc
JAVAH 	=	javah
DEBUG	=	-g
JFLAGS	=	-classpath $(CLASSPATH):jar/jta-26.jar:jar/jsch-0.1.42.jar
SRCDIR	=	de
PKGNAME	=	jta-ssh-0.1
VERSION	=	`java -version 2>&1 | head -1 | \
		 sed 's/^java version //' | sed 's/"//g'`
DATE	=	`date +%Y%m%d-%H%M`

.SUFFIXES:	.java .class

# compile java files to class
.java.class:
	$(JAVAC) $(DEBUG) $(JFLAGS) $<

#
# major rules to create files
#
all: 	app doc jar

run:	app
	$(JAVA) $(JFLAGS) de.mud.jta.Main

doc:	app
	@echo Creating source documentation ...
	@if [ ! -d doc ]; then mkdir doc; fi
	@-rm -r doc/source/*.html doc/source/de
	@$(JAVADOC) -d doc/source -version -author \
	-sourcepath $(CLASSPATH):. \
	`(find de -name \*.java -printf '%h\n'; \
		) | \
		sort | uniq | \
		grep -v CVS | sed 's/\//./g'`; > /dev/null
	@echo Source documentation done.

jar:	app
	@echo Creating binary archive ...
	@if [ ! -d jar ]; then mkdir jar; fi
	@touch "Created-$(DATE)"
	@$(JAR) cvfm jar/$(PKGNAME).jar \
	  "Created-$(DATE)" \
	  `find $(SRCDIR) -name \*.class` \
	  `find $(SRCDIR) -name \*.properties` > /dev/null
	@rm -f Created-*
	@echo Created jar/$(PKGNAME).jar

# 
# application dependencies
#
app:
	@find $(SRCDIR) -name \*.java | sed 's/java$$/class/' | xargs make
	@echo Done.

changes:
	@rcs2log > CHANGES
	@echo Created CHANGES.

clean:
	-find . -name \*.class -print | xargs rm > /dev/null 2>&1
	-find . -name \*~ -print | xargs rm > /dev/null 2>&1

realclean: clean
	-rm -f jar/$(PKGNAME).jar jar/$(PKGNAME)-src.jar
